/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.sac.be;

import edu.upn.sigemfi.seg.be.Persona;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Colao
 */
@Entity
@Table(name = "SAC_SOLICITANTE_CREDITO", catalog = "SIGEMFI", schema = "dbo")
@NamedQueries({@NamedQuery(name = "SolicitanteCredito.findAll", query = "SELECT s FROM SolicitanteCredito s"), @NamedQuery(name = "SolicitanteCredito.findByFidSegPersona", query = "SELECT s FROM SolicitanteCredito s WHERE s.solicitanteCreditoPK.fidSegPersona = :fidSegPersona"), @NamedQuery(name = "SolicitanteCredito.findByFidSacSolicitudCredito", query = "SELECT s FROM SolicitanteCredito s WHERE s.solicitanteCreditoPK.fidSacSolicitudCredito = :fidSacSolicitudCredito"), @NamedQuery(name = "SolicitanteCredito.findByEstado", query = "SELECT s FROM SolicitanteCredito s WHERE s.estado = :estado"), @NamedQuery(name = "SolicitanteCredito.findByCalificacionCentralRiesgos", query = "SELECT s FROM SolicitanteCredito s WHERE s.calificacionCentralRiesgos = :calificacionCentralRiesgos")})
public class SolicitanteCredito implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SolicitanteCreditoPK solicitanteCreditoPK;
    @Column(name = "ESTADO")
    private Short estado;
    @Column(name = "CALIFICACION_CENTRAL_RIESGOS")
    private Short calificacionCentralRiesgos;
    @JoinColumn(name = "FID_SAC_SOLICITUD_CREDITO", referencedColumnName = "ID_SOLICITUDCREDITO", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private SolicitudCredito solicitudCredito;

    @JoinColumn(name = "FID_SEG_PERSONA", referencedColumnName = "ID_PERSONA", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Persona persona;

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    

    public SolicitanteCredito() {
    }

    public SolicitanteCredito(SolicitanteCreditoPK solicitanteCreditoPK) {
        this.solicitanteCreditoPK = solicitanteCreditoPK;
    }

    public SolicitanteCredito(long fidSegPersona, long fidSacSolicitudCredito) {
        this.solicitanteCreditoPK = new SolicitanteCreditoPK(fidSegPersona, fidSacSolicitudCredito);
    }

    public SolicitanteCreditoPK getSolicitanteCreditoPK() {
        return solicitanteCreditoPK;
    }

    public void setSolicitanteCreditoPK(SolicitanteCreditoPK solicitanteCreditoPK) {
        this.solicitanteCreditoPK = solicitanteCreditoPK;
    }

    public Short getEstado() {
        return estado;
    }

    public void setEstado(Short estado) {
        this.estado = estado;
    }

    public Short getCalificacionCentralRiesgos() {
        return calificacionCentralRiesgos;
    }

    public void setCalificacionCentralRiesgos(Short calificacionCentralRiesgos) {
        this.calificacionCentralRiesgos = calificacionCentralRiesgos;
    }

    public SolicitudCredito getSolicitudCredito() {
        return solicitudCredito;
    }

    public void setSolicitudCredito(SolicitudCredito solicitudCredito) {
        this.solicitudCredito = solicitudCredito;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (solicitanteCreditoPK != null ? solicitanteCreditoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SolicitanteCredito)) {
            return false;
        }
        SolicitanteCredito other = (SolicitanteCredito) object;
        if ((this.solicitanteCreditoPK == null && other.solicitanteCreditoPK != null) || (this.solicitanteCreditoPK != null && !this.solicitanteCreditoPK.equals(other.solicitanteCreditoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.sac.be.SolicitanteCredito[solicitanteCreditoPK=" + solicitanteCreditoPK + "]";
    }

}
